package com.coderman.domainservice.blogtopic.adapter.admin;

import com.coderman.domainservice.blogtopic.app.command.PublishBlogCmd;
import com.coderman.domainservice.blogtopic.app.command.PublishBlogCommentCmd;
import com.coderman.domainservice.blogtopic.app.command.PublishBlogSpecialColumnCmd;
import com.coderman.domainservice.blogtopic.app.executor.PublishBlogCmdExe;
import com.coderman.domainservice.blogtopic.app.executor.PublishBlogCommentCmdExe;
import com.coderman.domainservice.blogtopic.app.executor.PublishBlogSpecialColumnCmdExe;
import com.coderman.domainservice.blogtopic.client.dto.BlogCommentDTO;
import com.coderman.domainservice.blogtopic.client.dto.BlogDTO;
import com.coderman.domainservice.blogtopic.client.dto.BlogSpecialColumnDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Description:
 * date: 2021/3/30
 *
 * @author shenshuai
 * @version 1.0.0
 * @since JDK 1.8
 * 管理后台，主要指用户登陆之后对自己的博客进行curd,比如已发布可以再次修改
 *
 */
@RestController
public class BlogManageController {

    @Autowired
    private PublishBlogCmdExe publishBlogCmdExe;

    @Autowired
    private PublishBlogCommentCmdExe publishBlogCommentCmdExe;

    @Autowired
    private PublishBlogSpecialColumnCmdExe publishBlogSpecialColumnCmdExe;


    @RequestMapping(value = "/blog/publish")
    public String publishBlog(@RequestBody BlogDTO blogDTO){
        PublishBlogCmd publishBlogCmd = new PublishBlogCmd();
        publishBlogCmd.setBlogDTO(blogDTO);
        publishBlogCmdExe.execute(publishBlogCmd);
        return "";
    }

    @RequestMapping(value = "/comment/publish")
    public String publishComment(@RequestBody BlogCommentDTO blogCommentDTO){
        PublishBlogCommentCmd publishBlogCommentCmd = new PublishBlogCommentCmd();
        publishBlogCommentCmd.setBlogCommentDTO(blogCommentDTO);
        publishBlogCommentCmdExe.execute(publishBlogCommentCmd);
        return "";
    }

    @RequestMapping(value = "/specialcolumn/publish")
    public String publishSpecialColumn(@RequestBody BlogSpecialColumnDTO blogCommentDTO){
        PublishBlogSpecialColumnCmd publishBlogCommentCmd = new PublishBlogSpecialColumnCmd();
        publishBlogCommentCmd.setBlogSpecialColumnDTO(blogCommentDTO);
        publishBlogSpecialColumnCmdExe.execute(publishBlogCommentCmd);
        return "";
    }
}
